/**
 * 版权所有：厦门市巨龙信息科技有限公司
 * Copyright 2023 Xiamen Dragoninfo Eng. Co. Ltd.
 * All right reserved.
 */
package com.github.alfred.common;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 类说明
 *
 * @author chengh
 * @date 2023/4/11 15:51
 */

public class PageResult<T> implements Serializable {

    private static final long serialVersionUID = - 4096316195873442639L;

    private long total;
    private List<T> data;

    public static <T> PageResult<T> build(List<T> list, long total) {
        PageResult<T> result = new PageResult<>();
        result.setTotal(total);
        result.setData(list);
        return result;
    }

    public static <T> PageResult<T> empty() {
        PageResult<T> result = new PageResult<>();
        result.setTotal(0);
        result.setData(new ArrayList<>());
        return result;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }
}
